package com.hxy.travel.entity;

import com.hxy.travel.constant.MessageConstant;

import java.io.Serializable;

public class Result implements Serializable {

    private  boolean flag;
    private Object data;
    private String message;
    public static Result data(Object data , String message ){
        Result result = Result.ok();
        result.setData(data);
        result.setMessage(message);

        return result;
    }

    public static Result data(Object data ){
        Result result = Result.ok();
        result.setData(data);
        return result;
    }
    public static Result ok(){
        Result result = new Result();
        result.setFlag(true);
        result.setMessage(MessageConstant.SUCCESS);
        return result;
    }
    public static Result ok(String message){
        Result result = new Result();
        result.setFlag(true);
        result.setMessage(message);
        return result;
    }
    public static Result fail(){
        Result result = new Result();
        result.setFlag(false);
        result.setMessage(MessageConstant.FAIL);
        return result;
    }
    public static Result fail(String message ){
        Result result = new Result();
        result.setFlag(false);
        result.setMessage(message);
        return result;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
